import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

//导入对应的路由页面
// import Center from "../views/center/Center.vue"

//导入创建好的路由模块
import centerRoutes from './routers/center'
import cinemaRoutes from './routers/cinema'
import filmRoutes from './routers/film'
//导入详情页模块
import Detial from '../views/detial/Detial.vue'
//导入城市模块
import City from '../views/city/City.vue'
//导入登录页面模块
import Login from '../views/center/Login.vue'
//导入注册页面模块
import Register from '../views/center/Register.vue'


const routes = [
  //解构个人中心的路由数组，最终将多个模块组合成一个大数组
  ...centerRoutes,
  //解构电影院的路由数组
  ...cinemaRoutes,
  //解构电影的路由数组
  ...filmRoutes,
  //重定向到正在上映页面
  {
    path: '/',
    redirect: '/film/newplaying'
  },
  //电影详情页路由
  {
    path: '/film/detial/:filmid',
    name: 'Detial',
    component: Detial
  },
  //城市列表路由
  {
    path: '/city',
    name: 'City',
    component: City
  },
  //登录页面路由
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  //注册页面路由
  {
    path: '/register',
    name: 'Register',
    component: Register
  }
]

const router = new VueRouter({
  mode: 'history', //路由模式切换为history，默认是hash
  base: process.env.BASE_URL,
  routes
})

export default router
